-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
match lowering: handle or-patterns one layer at a time #122046
Conversation
1d7c466
to
c7a1c2b
Compare
This comment was marked as resolved.
This comment was marked as resolved.
c7a1c2b
to
bd0334f
Compare
Gentle ping on this one, I got a few things blocked on it |
…i-obk match lowering: consistently merge simple or-patterns There are two places where we expand or-patterns in match lowering: the main one is `test_candidates_with_or`, and there's one in `match_candidates` that's an optimization for the simple case where the whole pattern is just one or-pattern. To reduce duplication, we merge or-pattern alternatives into a single block when possible, but we only to that in `test_candidates_with_or`. This PR fixes this oversight and merges them in `match_candidates` too. This is a part of splitting up rust-lang#122046 into smaller bits.
Rollup merge of rust-lang#123067 - Nadrieril:always-simplify-or, r=oli-obk match lowering: consistently merge simple or-patterns There are two places where we expand or-patterns in match lowering: the main one is `test_candidates_with_or`, and there's one in `match_candidates` that's an optimization for the simple case where the whole pattern is just one or-pattern. To reduce duplication, we merge or-pattern alternatives into a single block when possible, but we only to that in `test_candidates_with_or`. This PR fixes this oversight and merges them in `match_candidates` too. This is a part of splitting up rust-lang#122046 into smaller bits.
This comment has been minimized.
This comment has been minimized.
By calling back into `match_candidates`, we only need to expand one layer at a time. Conversely, since we always try to simplify a layer that we just expanded, we only have to merge one layer at a time.
15de647
to
23c9f69
Compare
r? @oli-obk |
Sorry about taking so long on this |
☀️ Test successful - checks-actions |
Finished benchmarking commit (6bb6b81): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 669.305s -> 667.497s (-0.27%) |
create_or_subcandidates
andmerge_trivial_subcandidates
both call themselves recursively to handle nested or-patterns, which is hard to follow. In this PR I avoid the need for that; we now process a single "layer" of or-patterns at a time.By calling back into
match_candidates
, we only need to expand one layer at a time. Conversely, since we always try to simplify a layer that we just expanded (thanks to #123067), we only have to merge one layer at a time.r? @matthewjasper